import React,{ Component } from 'react';
import './index.css';
import pubsub from 'pubsub-js'
class Head extends Component{
  constructor(props){
    super(props);
    this.state ={
      title:''
    }
  }
  inpHandle = (e) =>{
    this.setState({
        title:e.target.value
    })
  }
  render(h) {
    return(
        <div className='home_search'>
          <input placeholder='请输入书籍名词' onChange={this.inpHandle}/>
          <button onClick={()=>pubsub.publish('search',this.state.title)}>搜索</button>
          <button onClick={()=>pubsub.publish('sort')}>排序</button>
        </div>
    )
  }
}

export default Head;